package bservice

import (
    "github.com/opentracing/opentracing-go"
    "github.com/uber/jaeger-client-go"
    "github.com/uber/jaeger-client-go/config"
    "io"
    "time"
)

func (Service) TraceBoot(serviceName, hostPort string, maxPacketSize int) (tracer opentracing.Tracer, closer io.Closer, err error) {
    cfg := config.Configuration{
        ServiceName: serviceName,
        Sampler: &config.SamplerConfig{
            Type:  jaeger.SamplerTypeConst,
            Param: 1,
        },
        Reporter: &config.ReporterConfig{
            LogSpans:            true,
            BufferFlushInterval: time.Second,
        },
    }
    sender, err := jaeger.NewUDPTransport(hostPort, maxPacketSize)
    if err != nil {
        return
    }
    reporter := jaeger.NewRemoteReporter(sender)
    tracer, closer, err = cfg.NewTracer(config.Reporter(reporter))
    return
}
